/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package transactions;

import java.sql.Date;
import javax.persistence.*;
import myJPA.Model;
import user.Employee;



/**
 *
 * @author Nacer Khalil
 */
@Entity
@Table(name="late_charge")
@NamedQueries({
@NamedQuery(name="getLateCharges", query="select l from LateCharge l where rental.customer=:c AND chargeStatus=false"),
@NamedQuery(name="getLateCharge",query="select l from LateCharge l where l.rental.customer.id =:cus_id AND l.rental.item.id =:item_id")

})
public class LateCharge extends Model{
    
    @Id
    @GeneratedValue
    private int id;
    
    @OneToOne
    private Rental rental;
    
    @ManyToOne
    private Employee employee;
    
    private int amountCharged;
    private int amountPaid;
    private boolean chargeStatus;
    private Date returnDate;

    public LateCharge() {
        super();
    }

    public LateCharge(Rental rental, Employee employee, int amountCharged, int amountPaid, boolean chargeStatus, Date returnDate) {
        this.rental = rental;
        this.employee = employee;
        this.amountCharged = amountCharged;
        this.amountPaid = amountPaid;
        this.chargeStatus = chargeStatus;
        this.returnDate = returnDate;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @return the rental
     */
    public Rental getRental() {
        return rental;
    }

    /**
     * @param rental the rental to set
     */
    public void setRental(Rental rental) {
        this.rental = rental;
    }

    /**
     * @return the amountCharged
     */
    public int getAmountCharged() {
        return amountCharged;
    }

    /**
     * @return the amountPaid
     */
    public int getAmountPaid() {
        return amountPaid;
    }

    /**
     * @param amountPaid the amountPaid to set
     */
    public void setAmountPaid(int amountPaid) {
        this.amountPaid = amountPaid;
    }

    /**
     * @return the chargeStatus
     */
    public boolean isChargeStatus() {
        return chargeStatus;
    }

    /**
     * @param chargeStatus the chargeStatus to set
     */
    public void setChargeStatus(boolean chargeStatus) {
        this.chargeStatus = chargeStatus;
    }

    /**
     * @return the returnDate
     */
    public Date getReturnDate() {
        return returnDate;
    }

    /**
     * @param returnDate the returnDate to set
     */
    public void setReturnDate(Date returnDate) {
        this.returnDate = returnDate;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LateCharge other = (LateCharge) obj;
        if (this.id != other.id) {
            return false;
        }
        if (this.rental != other.rental && (this.rental == null || !this.rental.equals(other.rental))) {
            return false;
        }
        if (this.employee != other.employee && (this.employee == null || !this.employee.equals(other.employee))) {
            return false;
        }
        if (this.amountCharged != other.amountCharged) {
            return false;
        }
        if (this.amountPaid != other.amountPaid) {
            return false;
        }
        if (this.chargeStatus != other.chargeStatus) {
            return false;
        }
        if (this.returnDate != other.returnDate && (this.returnDate == null || !this.returnDate.equals(other.returnDate))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        return hash;
    }
    
    
    
    
}
